<?
require_once('TextConverter.php');

class TextConverterTest extends PHPUnit_Framework_TestCase {
	protected $c;
	protected function setUp() {
		$this->c= new TextConverter;
	}
	function testGetAsString() {
		$this->assertNull($this->c->getAsString(null));
		
		$this->assertSame('',$this->c->getAsString(''));
		$this->assertSame('',$this->c->getAsString(array()));
		$this->assertSame('',$this->c->getAsString(false));
		$this->assertSame('',$this->c->getAsString(0));

		$this->assertSame('0',$this->c->getAsString('0'));
		$this->assertSame('1',$this->c->getAsString(true));
		$this->assertSame('1231',$this->c->getAsString(1231));
		$this->assertSame('wqwe',$this->c->getAsString('wqwe'));
		$this->assertSame("line1\n\rline2",$this->c->getAsString("line1\n\rline2"));
	}
	function testGetAsDatatype() {
		$this->assertNull($this->c->getAsDatatype(null));

		$this->assertSame('1',$this->c->getAsDatatype('1'));
		$this->assertSame('123',$this->c->getAsDatatype(123));
		$this->assertSame('Array',$this->c->getAsDatatype(array(12)));
		$this->assertSame('0',$this->c->getAsDatatype('0'));
		$this->assertSame('0',$this->c->getAsDatatype(0));
		$this->assertSame("line1\nline2",$this->c->getAsDatatype("line1\n\rline2"));
	}
}
